package com.meshnetics.gb.util.formatters;

import com.meshnetics.gb.util.ByteBufferManager;
import com.meshnetics.gb.util.checkers.RangeCheckers;

import java.nio.ByteBuffer;

/**
 * NumberFormatter implementation for u-short.
 *
 * @author Yury Aserchev (yaserchev@meshnetics.com)
 *         Date: 20.06.2008 18:28:10
 */
final class NumberFormatterUShort extends AbstractNumberFormatter {
    protected ByteBuffer getBuffer(final long value) {
        return ByteBufferManager.allocateBE(Short.SIZE / Byte.SIZE).putShort((short) value);
    }

    protected void checkRange(final long value) {
        RangeCheckers.USHORT.checkRange(value);
    }
}
